package ch.fhnw.kosmonauten.model;

import java.io.Serializable;
import java.util.Locale;
import java.util.ResourceBundle;

@SuppressWarnings("serial")
public class User implements Serializable {
	
	//Attributs
	private int id;
	private String username;
	private String password;
	private String role;
	private Locale currentLocale;
	
	//Getter Methods
	public int getId() {
		return id;
	}
	public String getUsername() {
		return username;
	}
	public String getPassword() {
		return password;
	}
	public String getRole() {
		return role;
	}
	public Locale getLanguage(){
		return currentLocale;
	}
	
	//Setter Methods
	public void setId(int id) {
		this.id = id;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public void setRole(String role) {
		this.role = role;
	}
	public void setLanguage(Locale currentLocale){
		this.currentLocale = currentLocale;
	}
	
	//Constructor
	public User(int id, String username, String password, String role, String language){
		this.id = id;
		this.username = username;
		this.password = password;
		this.role = role;
		if (language.equalsIgnoreCase("de")){
			this.currentLocale = Locale.GERMAN;
		}
		else if (language.equalsIgnoreCase("en")){
			this.currentLocale = Locale.ENGLISH;
		}
		else
			this.currentLocale = Locale.GERMAN;
	}
	//Constructor
	public User(){
		this.currentLocale = Locale.GERMAN;
	}
	
	public String displayValue(String key) {
		
		if(this.currentLocale.equals(Locale.ENGLISH) || this.currentLocale.equals(Locale.GERMAN)){
			ResourceBundle labels = ResourceBundle.getBundle("LabelsBundle", this.currentLocale);
			String value  = labels.getString(key);
			return value;
		}
		else {
			ResourceBundle labels = ResourceBundle.getBundle("LabelsBundle", Locale.GERMAN);
			String value  = labels.getString(key);
			return value;
		}


	}

}
